/*
 * @Author: liyongxuan
 * @Date: 2018-04-26 14:36:37
 * @description: 事件主体
*/

import { apiHttp } from '../apiHttp';
import Api from '../../api/event/eventController.api';
import PersonApi from '../../api/person/personController.api';
import { JsonResult, EventDto, EventDelDto, ComIpoVO } from '../../api/Interface';
import { EventSearchDto, SearchTitleDto, PersonSearchDto } from './Interface';


export default {
    // 根据事件类型和标题模糊匹配事件名称
    getSearchTitle: async (searchTitleDto: SearchTitleDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.searchTitle, searchTitleDto);
      return res;
    },
    // 获取事件主列表上方的总数统计（待完善信息/已发布信息/质检未通过信息）
    getEventCountInfo: async (eventType: number): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.getEventCountInfo, {eventType});
      return res.data;
    },
    // 添加事件基本信息
    addSaveEvent: async (eventDto: EventDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.saveEvent, eventDto);
      return res;
    },
    // 删除选择数据
    delEventById: async (eventDelDto: EventDelDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.deleteEventById, eventDelDto);
      return res;
    },
    // 修改事件基本信息
    updateEvent: async (eventDto: EventDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.updateEvent, eventDto);
      return res;
    },
    // 获取事件列表
    getEventPage: async (eventSearchDto: EventSearchDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.EventPage, eventSearchDto);
      return res;
    },
    // 根据当前企业/工商id查询上市交易所信息
    getComIpo: async (companyId: string): Promise<Array<ComIpoVO>> => {
      const res: JsonResult = await apiHttp(Api.getComIpo, {companyId});
      return res.data;
    },
    // 根据Id获取事件信息
    getEventDetail: async (id: string): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(Api.getEvent, {id});
      return res;
    },
    // 根据人物名称查询相关人物信息
    getInvestorInvestor: async (personSearchDto: PersonSearchDto): Promise<JsonResult> => {
      const res: JsonResult = await apiHttp(PersonApi.getInvestorInvestor, personSearchDto);
      return res;
    }
};